package com.leetcode.contest;

/**
 * @author `RKC`
 * @date 2021/11/7 10:30
 */
@SuppressWarnings("all")
public class LC5918统计字符串中的元音子字符串 {

    public static int countVowelSubstrings(String word) {
        if (word.length() < 5) return 0;
        int ans = 0;
        for (int i = 0; i < word.length(); i++) {
            if (!isValid(word.charAt(i))) continue;
            for (int j = i + 5; j <= word.length() && isValid(word.charAt(j - 1)); j++) {
                String s = word.substring(i, j);
                boolean[] flags = new boolean[5];
                boolean flag = true;
                for (int k = 0; k < s.length(); k++) {
                    if (s.charAt(k) == 'a') flags[0] = true;
                    else if (s.charAt(k) == 'e') flags[1] = true;
                    else if (s.charAt(k) == 'i') flags[2] = true;
                    else if (s.charAt(k) == 'o') flags[3] = true;
                    else if (s.charAt(k) == 'u') flags[4] = true;
                    else {
                        flag = false;
                        break;
                    }
                }
                for (boolean f : flags) {
                    if (!f) flag = false;
                }
                if (flag) {
                    ans++;
                    System.out.println(s);
                }
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(countVowelSubstrings("bbaeixoubb"));
    }

    private static boolean isValid(char c) {
        return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
    }
}
